<template>
    <div>
        登录页面
        <el-form
            :model="form"
            status-icon
            ref="ruleForm"
            label-width="100px"
            class="demo-ruleForm"
        >
            <el-form-item label="密码" prop="pass">
                <el-input
                    type="text"
                    v-model="form.userName"
                    autocomplete="off"
                ></el-input>
            </el-form-item>
            <el-form-item label="确认密码" prop="checkPass">
                <el-input
                    type="text"
                    v-model="form.password"
                    autocomplete="off"
                ></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="login">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
export default {
    data() {
        return {
            form: {
                userName: "jiyun",
                password: "password",
            },
        };
    },
    methods: {
        login() {
            this.$axios
                .post("/api/users/login", {
                    userName: this.form.userName,
                    password: this.form.password,
                })
                .then((res) => {
                    console.log(res);
                    localStorage.setItem("token",this.form.userName)
                    this.$router.push("/")
                });
        },
    },
    mounted() {},
};
</script>
